import os

from base_class import MyBase
from job_execute import JobExecutor

class Processor(MyBase):
	def __init__(self):
		MyBase.__init__(self)
		self.executor = JobExecutor()
		self.etl_script_path = os.path.join(os.getcwd(), 'scripts/etl')
		
	def file_list_process(self, file_list):
		for file in file_list:
			self.info('---etl [%s] processing...' % file)
			etl_script = self.get_etl_script(file)
			self.info('etl executor %s' % etl_script)
			self.executor.execute(etl_script)
			self.info('---etl [%s] processed...' % file)
	
	def get_etl_script(self, file):
		name = 'etl_' + file.split('.')[0] + '.py'
		file_path = os.path.join(self.etl_script_path, name)
		self.debug('get etl script %s' % file_path)
		return file_path
